import Work13.*;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
//        Teacher teacher=new Teacher("老师2","man",56,30);
//        teacher.printlf();
        People[]arr={new Teacher("老师1","man",26,3)
                ,new Teacher("老师2","man",56,30)
                , new Student("学生1","man",18,1)
                ,new Student("学生1","man",18,2)};
        Main am=new Main();
        am.budd(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
        for (int i = 0; i < arr.length; i++) {
            am.show(arr[i]);
        }
    }
    private void show(People people){
        if(people instanceof Student){
            ((Student)people).study();
        } else if (people instanceof Teacher) {
            ((Teacher) people).teach();
        }else {
            System.out.println("do nothing");
        }
    }
    public void budd(People []arr){
        People tem;
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if(arr[j].getAge()<arr[j+1].getAge()){
                    tem=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=tem;
                }
            }
        }
    }
}
